void mapping_spherical(in mapping_info_t info, out mapping_result_t result)
{
  float r = length(info.p);
  float ratio = info.p.z / r;

  float theta = atan(info.p.y, info.p.x);
  float phi = asin(ratio);

  result.uv.x = r * theta;
  result.uv.y = r * phi;

  float cos_theta = cos(theta);
  float sin_theta = sin(theta);
  float cos_phi = cos(phi);
  float sin_phi = ratio;

  result.t = -sin_theta*info.x + cos_theta*info.y;
  result.b = -cos_theta*sin_phi*info.x - sin_theta*sin_phi*info.y + cos_phi*info.z;
}
